package com.crm.system.schedule;

import com.crm.system.service.contactManager.ContactService;
import com.crm.system.service.customerManager.CustomerService;
import com.crm.system.service.returnMoney.ReturnMoneyService;
import com.crm.system.service.situationAware.SpiderService;
import com.xxl.job.core.context.XxlJobHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author yuanyunfeng
 * @date 2021/6/17 14:45
 */
@Slf4j
@Component
public class ScheduledService {

    @Autowired
    private SpiderService spiderService;

    @Autowired
    private ContactService contactService;

    @Autowired
    private ReturnMoneyService returnMoneyService;

    @Autowired
    CustomerService customerService;

    @Scheduled(cron = "0 */3 * * * ?")
    private void scheduled() {
        spiderService.insertFinancialNews();
    }

    @Scheduled(cron="0 0 0 * * ?")
    private void updateContactFollowPlanTime() {
        contactService.updateContactFollowPlanTime();
    }

    //@Scheduled(cron="0 2 0 1 * ?")
    //每月一号执行(统计业务员每月业绩)
    /*private void getSalesmanResults(){
        returnMoneyService.getSalesmanResults();
    }*/

    // 统计上个月各分公司会员新单/续费合同数量定时任务
//    @Scheduled(cron="0 0 0 1 * ?")
    private void statisticalVipContractCount(){
        char[] contractTypeArr = {'2', '4'}; // 2:会员新单合同; 4:会员续费合同;
        String result = customerService.statisticalVipContractCount(contractTypeArr);
        System.out.println("---------->" + result);
    }

}
